//### This file created by BYACC 1.8(/Java extension  1.15)
//### Java capabilities added 7 Jan 97, Bob Jamison
//### Updated : 27 Nov 97  -- Bob Jamison, Joe Nieten
//###           01 Jan 98  -- Bob Jamison -- fixed generic semantic constructor
//###           01 Jun 99  -- Bob Jamison -- added Runnable support
//###           06 Aug 00  -- Bob Jamison -- made state variables class-global
//###           03 Jan 01  -- Bob Jamison -- improved flags, tracing
//###           16 May 01  -- Bob Jamison -- added custom stack sizing
//###           04 Mar 02  -- Yuval Oren  -- improved java performance, added options
//###           14 Mar 02  -- Tomas Hurka -- -d support, static initializer workaround
//### Please send bug reports to tom@hukatronic.cz
//### static char yysccsid[] = "@(#)yaccpar	1.8 (Berkeley) 01/20/90";






//#line 2 "sintatico.y"
import java.io.*;
import analiseSemantica.*;


//#line 22 "Parser.java"




public class Parser
             implements ParserTokens
{

boolean yydebug;        //do I want debug output?
int yynerrs;            //number of errors so far
int yyerrflag;          //was there an error?
int yychar;             //the current working character

//########## MESSAGES ##########
//###############################################################
// method: debug
//###############################################################
void debug(String msg)
{
  if (yydebug)
    System.out.println(msg);
}

//########## STATE STACK ##########
final static int YYSTACKSIZE = 500;  //maximum stack size
int statestk[] = new int[YYSTACKSIZE]; //state stack
int stateptr;
int stateptrmax;                     //highest index of stackptr
int statemax;                        //state when highest index reached
//###############################################################
// methods: state stack push,pop,drop,peek
//###############################################################
final void state_push(int state)
{
  try {
		stateptr++;
		statestk[stateptr]=state;
	 }
	 catch (ArrayIndexOutOfBoundsException e) {
     int oldsize = statestk.length;
     int newsize = oldsize * 2;
     int[] newstack = new int[newsize];
     System.arraycopy(statestk,0,newstack,0,oldsize);
     statestk = newstack;
     statestk[stateptr]=state;
  }
}
final int state_pop()
{
  return statestk[stateptr--];
}
final void state_drop(int cnt)
{
  stateptr -= cnt; 
}
final int state_peek(int relative)
{
  return statestk[stateptr-relative];
}
//###############################################################
// method: init_stacks : allocate and prepare stacks
//###############################################################
final boolean init_stacks()
{
  stateptr = -1;
  val_init();
  return true;
}
//###############################################################
// method: dump_stacks : show n levels of the stacks
//###############################################################
void dump_stacks(int count)
{
int i;
  System.out.println("=index==state====value=     s:"+stateptr+"  v:"+valptr);
  for (i=0;i<count;i++)
    System.out.println(" "+i+"    "+statestk[i]+"      "+valstk[i]);
  System.out.println("======================");
}


//########## SEMANTIC VALUES ##########
//public class ParserVal is defined in ParserVal.java


String   yytext;//user variable to return contextual strings
ParserVal yyval; //used to return semantic vals from action routines
ParserVal yylval;//the 'lval' (result) I got from yylex()
ParserVal valstk[];
int valptr;
//###############################################################
// methods: value stack push,pop,drop,peek.
//###############################################################
void val_init()
{
  valstk=new ParserVal[YYSTACKSIZE];
  yyval=new ParserVal();
  yylval=new ParserVal();
  valptr=-1;
}
void val_push(ParserVal val)
{
  if (valptr>=YYSTACKSIZE)
    return;
  valstk[++valptr]=val;
}
ParserVal val_pop()
{
  if (valptr<0)
    return new ParserVal();
  return valstk[valptr--];
}
void val_drop(int cnt)
{
int ptr;
  ptr=valptr-cnt;
  if (ptr<0)
    return;
  valptr = ptr;
}
ParserVal val_peek(int relative)
{
int ptr;
  ptr=valptr-relative;
  if (ptr<0)
    return new ParserVal();
  return valstk[ptr];
}
final ParserVal dup_yyval(ParserVal val)
{
  ParserVal dup = new ParserVal();
  dup.ival = val.ival;
  dup.dval = val.dval;
  dup.sval = val.sval;
  dup.obj = val.obj;
  return dup;
}
//#### end semantic value section ####
public final static short YYERRCODE=256;
final static short yylhs[] = {                           -1,
    0,    1,    1,    1,    3,    3,    3,    3,    4,    5,
    5,    7,    7,    8,    8,    6,    6,    9,    9,    2,
    2,   10,   10,   11,   11,   11,   11,   11,   11,   11,
   11,   11,   11,   11,   11,   11,   11,   11,   11,   12,
   12,   14,   14,   13,   13,   17,   17,   17,   17,   17,
   17,   19,   19,   19,   18,   18,   16,   16,   15,   15,
   15,   22,   22,   22,   22,   21,   21,   21,   21,   21,
   21,   20,   20,
};
final static short yylen[] = {                            2,
    1,    5,    4,    3,    0,    3,    4,    4,    4,    0,
    1,    1,    3,    2,    4,    4,    3,    0,    5,    1,
    1,    1,    2,    1,    2,    3,    4,    2,    3,    6,
    6,    3,    3,    2,    2,    5,    7,    5,    1,    3,
    1,    3,    1,    2,    1,    4,    3,    1,    1,    3,
    4,    1,    1,    1,    1,    3,    1,    1,    1,    1,
    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
    1,    1,    1,
};
final static short yydefred[] = {                         0,
   20,   21,    0,    1,    0,    0,    0,    0,    4,    0,
    0,    0,    0,    0,    0,   11,    0,    0,    0,    0,
    0,    3,    0,    0,    0,    6,    0,    0,    2,    0,
    0,    9,   13,    7,    8,   15,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,   17,   24,   57,
   54,   52,    0,   58,   53,   39,    0,    0,    0,    0,
    0,    0,   45,   49,    0,    0,   28,    0,    0,    0,
    0,   34,   35,    0,    0,    0,    0,    0,   16,   23,
   25,    0,   70,   71,   62,   63,   64,   65,   66,   67,
   68,   69,   72,   73,    0,   59,   60,   61,   44,    0,
    0,   26,    0,   29,   33,   32,    0,    0,   50,   47,
   55,    0,    0,   40,   42,   19,   27,    0,    0,    0,
    0,    0,   46,   51,    0,    0,    0,   38,   56,   30,
   31,    0,   37,
};
final static short yydgoto[] = {                          3,
    4,    5,   12,    9,   15,   56,   16,   17,   38,   57,
   58,   59,   60,   61,   95,   62,   63,  112,   64,   96,
   97,   98,
};
final static short yysindex[] = {                      -239,
    0,    0,    0,    0, -254, -255, -206, -239,    0, -272,
 -249, -248, -239, -236, -210,    0, -202, -219, -189, -188,
 -239,    0, -200, -203, -239,    0, -219, -219,    0, -176,
 -239,    0,    0,    0,    0,    0, -193, -216, -219, -211,
 -192, -101, -172, -168, -159, -157,  -87,    0,    0,    0,
    0,    0, -266,    0,    0,    0, -163, -106, -162, -165,
   29,  -87,    0,    0, -150,  -73,    0, -147, -247, -146,
 -145,    0,    0,  -87,  -87, -139, -259,  -87,    0,    0,
    0,  -87,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,  -87,    0,    0,    0,    0, -239,
 -138,    0, -195,    0,    0,    0, -134, -133,    0,    0,
    0, -215, -132,    0,    0,    0,    0, -131, -130, -106,
 -106,  -87,    0,    0, -137, -129, -122,    0,    0,    0,
    0, -106,    0,
};
final static short yyrindex[] = {                         0,
    0,    0,    0,    0,    0,    0, -128, -126,    0,    0,
    0,    0,    0,    0,    0,    0, -125, -128,    0,    0,
    0,    0, -201,    0,    0,    0, -128, -128,    0,    0,
 -174,    0,    0,    0,    0,    0,    0,    0, -128,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,  -48,    0,    0,    0,    0, -115,    0,  -28,
 -166,    0,    0,    0,    0,    0,    0,    0,    0,   -9,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0, -174,
   10,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0, -140,    0,    0,    0,
    0,    0,    0,
};
final static short yygindex[] = {                         0,
    3,   -8,  -13,  156,    0,  140,  141,    0,   65,  111,
 -110,  -39,  -55,    0,    0,    0,    0,    0,    0,    0,
    0,    0,
};
final static int YYTABLESIZE=317;
static short yytable[];
static { yytable();}
static void yytable(){
yytable = new short[]{                         14,
   68,   77,   71,    6,   26,   78,   99,   76,   47,  127,
  128,  110,    8,   34,   35,   22,   14,    1,   18,    2,
   50,  133,   37,   29,  103,   65,   76,   21,  104,   51,
   52,   53,   54,   55,  107,  108,    7,  111,  113,  115,
   19,   20,  114,   40,   41,   42,   43,   44,   45,   10,
   46,   47,   11,  122,   23,  123,   66,   31,   48,   49,
   24,    8,   10,   50,   67,   11,   25,   14,   50,   14,
   31,   30,   51,   52,   53,   54,   55,   51,   52,   53,
   54,   55,  129,   27,   28,   18,   18,   18,   18,   18,
   18,   37,   18,   18,  118,  119,   36,   39,   69,   18,
   18,   18,   41,   72,   41,   18,   41,   73,   74,   41,
   75,   79,   82,   81,   18,   18,   18,   18,   18,   36,
   36,   36,   36,   36,   36,  100,   36,   36,  102,  105,
  106,  109,  117,   36,   36,   36,  120,  121,  130,   36,
  124,  125,  126,  132,   10,   12,  131,    5,   36,   36,
   36,   36,   36,   40,   41,   42,   43,   44,   45,   22,
   46,   47,   13,   32,  116,   33,   47,   31,   80,   49,
    0,    0,    0,   50,    0,    0,    0,    0,   50,    0,
   47,    0,   51,   52,   53,   54,   55,   70,   52,   53,
   54,   55,   50,    0,   47,    0,    0,    0,    0,    0,
    0,   51,   52,   53,   54,   55,   50,    0,    0,    0,
    0,    0,    0,    0,    0,   51,  101,   53,   54,   55,
   48,   48,   48,    0,   48,    0,    0,   48,   48,   48,
   48,   48,   48,   48,   48,   48,   48,   48,   48,   48,
   43,   43,   43,    0,   43,    0,    0,   43,   43,    0,
   43,   43,   43,   43,   43,   43,   43,   43,   43,   43,
   54,    0,    0,    0,    0,    0,    0,   54,   54,   54,
   54,   54,   54,   54,   54,   54,   54,   54,   54,   52,
    0,    0,    0,    0,    0,    0,   52,   52,   52,   52,
   52,   52,   52,   52,   52,   52,   52,   52,   83,    0,
    0,    0,    0,    0,    0,   84,    0,   85,   86,   87,
   88,   89,   90,   91,   92,   93,   94,
};
}
static short yycheck[];
static { yycheck(); }
static void yycheck() {
yycheck = new short[] {                          8,
   40,  268,   42,  258,   18,  272,   62,   47,  268,  120,
  121,  271,  268,   27,   28,   13,   25,  257,  291,  259,
  280,  132,   31,   21,  272,   39,   66,  276,  276,  289,
  290,  291,  292,  293,   74,   75,  291,   77,   78,   95,
  290,  291,   82,  260,  261,  262,  263,  264,  265,  269,
  267,  268,  272,  269,  291,  271,  268,  274,  275,  276,
  271,  268,  269,  280,  276,  272,  269,  269,  280,  271,
  274,  272,  289,  290,  291,  292,  293,  289,  290,  291,
  292,  293,  122,  273,  273,  260,  261,  262,  263,  264,
  265,  100,  267,  268,  290,  291,  273,  291,  291,  274,
  275,  276,  269,  276,  271,  280,  273,  276,  268,  276,
  268,  275,  278,  276,  289,  290,  291,  292,  293,  260,
  261,  262,  263,  264,  265,  276,  267,  268,  276,  276,
  276,  271,  271,  274,  275,  276,  271,  271,  276,  280,
  273,  273,  273,  266,  271,  271,  276,  276,  289,  290,
  291,  292,  293,  260,  261,  262,  263,  264,  265,  275,
  267,  268,    7,   24,  100,   25,  268,  274,   58,  276,
   -1,   -1,   -1,  280,   -1,   -1,   -1,   -1,  280,   -1,
  268,   -1,  289,  290,  291,  292,  293,  289,  290,  291,
  292,  293,  280,   -1,  268,   -1,   -1,   -1,   -1,   -1,
   -1,  289,  290,  291,  292,  293,  280,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,  289,  290,  291,  292,  293,
  269,  270,  271,   -1,  273,   -1,   -1,  276,  277,  278,
  279,  280,  281,  282,  283,  284,  285,  286,  287,  288,
  269,  270,  271,   -1,  273,   -1,   -1,  276,  277,   -1,
  279,  280,  281,  282,  283,  284,  285,  286,  287,  288,
  270,   -1,   -1,   -1,   -1,   -1,   -1,  277,  278,  279,
  280,  281,  282,  283,  284,  285,  286,  287,  288,  270,
   -1,   -1,   -1,   -1,   -1,   -1,  277,  278,  279,  280,
  281,  282,  283,  284,  285,  286,  287,  288,  270,   -1,
   -1,   -1,   -1,   -1,   -1,  277,   -1,  279,  280,  281,
  282,  283,  284,  285,  286,  287,  288,
};
}
final static short YYFINAL=3;
final static short YYMAXTOKEN=293;
final static String yyname[] = {
"end-of-file",null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
null,null,null,"INT","MAIN","CHAR","RETURN","READ","WRITE","WRITELN","BREAK",
"IF","ELSE","WHILE","PARENTESEESQUERDO","VIRGULA","MAIOR","PARENTESEDIREITO",
"COLCHETEESQUERDO","COLCHETEDIREITO","CHAVEESQUERDO","CHAVEDIREITO",
"PONTOVIRGULA","MAIORIGUAL","ATRIBUICAO","OPADICAO","OPSUBTRACAO","OPMULT",
"OPDIVISAO","IGUALDADE","DIFERENCA","MENOR","MENORIGUAL","OR","AND","STR","NUM",
"ID","NEGACAO","CCHAR",
};
final static String yyrule[] = {
"$accept : Program",
"Program : Decls",
"Decls : Type ID VarDecl PONTOVIRGULA Decls",
"Decls : Type ID FuncDecl Decls",
"Decls : Type MAIN FuncDecl",
"VarDecl :",
"VarDecl : VIRGULA ID VarDecl",
"VarDecl : COLCHETEESQUERDO NUM COLCHETEDIREITO VarDecl",
"VarDecl : COLCHETEESQUERDO ID COLCHETEDIREITO VarDecl",
"FuncDecl : PARENTESEESQUERDO ParamDeclList PARENTESEDIREITO Block",
"ParamDeclList :",
"ParamDeclList : ParamDeclListTail",
"ParamDeclListTail : ParamDecl",
"ParamDeclListTail : ParamDecl VIRGULA ParamDeclListTail",
"ParamDecl : Type ID",
"ParamDecl : Type ID COLCHETEESQUERDO COLCHETEDIREITO",
"Block : CHAVEESQUERDO VarDeclList StmtList CHAVEDIREITO",
"Block : CHAVEESQUERDO VarDeclList CHAVEDIREITO",
"VarDeclList :",
"VarDeclList : Type ID VarDecl PONTOVIRGULA VarDeclList",
"Type : INT",
"Type : CHAR",
"StmtList : Stmt",
"StmtList : Stmt StmtList",
"Stmt : PONTOVIRGULA",
"Stmt : Expr PONTOVIRGULA",
"Stmt : RETURN Expr PONTOVIRGULA",
"Stmt : RETURN PARENTESEESQUERDO NUM PARENTESEDIREITO",
"Stmt : RETURN PONTOVIRGULA",
"Stmt : READ ID PONTOVIRGULA",
"Stmt : READ ID COLCHETEESQUERDO NUM COLCHETEDIREITO PONTOVIRGULA",
"Stmt : READ ID COLCHETEESQUERDO ID COLCHETEDIREITO PONTOVIRGULA",
"Stmt : WRITE Expr PONTOVIRGULA",
"Stmt : WRITE STR PONTOVIRGULA",
"Stmt : WRITELN PONTOVIRGULA",
"Stmt : BREAK PONTOVIRGULA",
"Stmt : IF PARENTESEESQUERDO Expr PARENTESEDIREITO Stmt",
"Stmt : IF PARENTESEESQUERDO Expr PARENTESEDIREITO Stmt ELSE Stmt",
"Stmt : WHILE PARENTESEESQUERDO Expr PARENTESEDIREITO Stmt",
"Stmt : Block",
"Expr : UnaryExpr ATRIBUICAO Expr",
"Expr : BinaryExpr",
"BinaryExpr : BinaryExpr BinOp UnaryExpr",
"BinaryExpr : UnaryExpr",
"UnaryExpr : UnaryOp UnaryExpr",
"UnaryExpr : PostFixExpr",
"PostFixExpr : ID PARENTESEESQUERDO ArgumentList PARENTESEDIREITO",
"PostFixExpr : ID PARENTESEESQUERDO PARENTESEDIREITO",
"PostFixExpr : ID",
"PostFixExpr : Constant",
"PostFixExpr : PARENTESEESQUERDO Expr PARENTESEDIREITO",
"PostFixExpr : ID COLCHETEESQUERDO Expr COLCHETEDIREITO",
"Constant : NUM",
"Constant : CCHAR",
"Constant : STR",
"ArgumentList : Expr",
"ArgumentList : ArgumentList VIRGULA Expr",
"UnaryOp : OPSUBTRACAO",
"UnaryOp : NEGACAO",
"BinOp : BooleanOp",
"BinOp : RelOp",
"BinOp : AritmOp",
"AritmOp : OPADICAO",
"AritmOp : OPSUBTRACAO",
"AritmOp : OPMULT",
"AritmOp : OPDIVISAO",
"RelOp : IGUALDADE",
"RelOp : DIFERENCA",
"RelOp : MENOR",
"RelOp : MENORIGUAL",
"RelOp : MAIOR",
"RelOp : MAIORIGUAL",
"BooleanOp : OR",
"BooleanOp : AND",
};

//#line 153 "sintatico.y"

private Yylex lexer;

int numLinha = 1;
public void yyerror (String error) {
	System.err.println("ERRO : " + error + " " + lexer.getLineNum()); 
	System.err.println("Entrada rejeitada");
	System.exit(0);
}

public void erroSemantico(String error){
	System.err.println("ERRO : " + error + " " + lexer.getLineNum());
	System.exit(0);
}

public int currLine(){
    return lexer.getLineNum()+1;
}


private int yylex() {
	int retVal = -1;
	try {
		yylval = new ParserVal(0); //zera o valor do token
		retVal = lexer.yylex(); //le a entrada do arquivo e retorna um token
	} catch (IOException e) {
		System.err.println("IO Erro:" + e);
	}
	return retVal; //retorna o token para o Parser
}


public Parser (Reader r) {
	lexer = new Yylex (r, this);
}


public static void main (String   args[]) throws IOException {
	int yychar;
	Parser yyparser = new Parser(new FileReader(args[0]));
	yyparser.yydebug = false;
	yyparser.yyparse(); // dispara o processo de analise sintatica e lexica
	System.out.println("ANALISE SINTATICA OK");
	System.out.println("ANALISE SEMANTICA OK");
}




//#line 437 "Parser.java"
//###############################################################
// method: yylexdebug : check lexer state
//###############################################################
void yylexdebug(int state,int ch)
{
String s=null;
  if (ch < 0) ch=0;
  if (ch <= YYMAXTOKEN) //check index bounds
     s = yyname[ch];    //now get it
  if (s==null)
    s = "illegal-symbol";
  debug("state "+state+", reading "+ch+" ("+s+")");
}





//The following are now global, to aid in error reporting
int yyn;       //next next thing to do
int yym;       //
int yystate;   //current parsing state from state table
String yys;    //current token string


//###############################################################
// method: yyparse : parse input and execute indicated items
//###############################################################
int yyparse()
{
boolean doaction;
  init_stacks();
  yynerrs = 0;
  yyerrflag = 0;
  yychar = -1;          //impossible char forces a read
  yystate=0;            //initial state
  state_push(yystate);  //save it
  val_push(yylval);     //save empty value
  while (true) //until parsing is done, either correctly, or w/error
    {
    doaction=true;
    if (yydebug) debug("loop"); 
    //#### NEXT ACTION (from reduction table)
    for (yyn=yydefred[yystate];yyn==0;yyn=yydefred[yystate])
      {
      if (yydebug) debug("yyn:"+yyn+"  state:"+yystate+"  yychar:"+yychar);
      if (yychar < 0)      //we want a char?
        {
        yychar = yylex();  //get next token
        if (yydebug) debug(" next yychar:"+yychar);
        //#### ERROR CHECK ####
        if (yychar < 0)    //it it didn't work/error
          {
          yychar = 0;      //change it to default string (no -1!)
          if (yydebug)
            yylexdebug(yystate,yychar);
          }
        }//yychar<0
      yyn = yysindex[yystate];  //get amount to shift by (shift index)
      if ((yyn != 0) && (yyn += yychar) >= 0 &&
          yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
        {
        if (yydebug)
          debug("state "+yystate+", shifting to state "+yytable[yyn]);
        //#### NEXT STATE ####
        yystate = yytable[yyn];//we are in a new state
        state_push(yystate);   //save it
        val_push(yylval);      //push our lval as the input for next rule
        yychar = -1;           //since we have 'eaten' a token, say we need another
        if (yyerrflag > 0)     //have we recovered an error?
           --yyerrflag;        //give ourselves credit
        doaction=false;        //but don't process yet
        break;   //quit the yyn=0 loop
        }

    yyn = yyrindex[yystate];  //reduce
    if ((yyn !=0 ) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
      {   //we reduced!
      if (yydebug) debug("reduce");
      yyn = yytable[yyn];
      doaction=true; //get ready to execute
      break;         //drop down to actions
      }
    else //ERROR RECOVERY
      {
      if (yyerrflag==0)
        {
        yyerror("syntax error");
        yynerrs++;
        }
      if (yyerrflag < 3) //low error count?
        {
        yyerrflag = 3;
        while (true)   //do until break
          {
          if (stateptr<0)   //check for under & overflow here
            {
            yyerror("stack underflow. aborting...");  //note lower case 's'
            return 1;
            }
          yyn = yysindex[state_peek(0)];
          if ((yyn != 0) && (yyn += YYERRCODE) >= 0 &&
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
            {
            if (yydebug)
              debug("state "+state_peek(0)+", error recovery shifting to state "+yytable[yyn]+" ");
            yystate = yytable[yyn];
            state_push(yystate);
            val_push(yylval);
            doaction=false;
            break;
            }
          else
            {
            if (yydebug)
              debug("error recovery discarding state "+state_peek(0)+" ");
            if (stateptr<0)   //check for under & overflow here
              {
              yyerror("Stack underflow. aborting...");  //capital 'S'
              return 1;
              }
            state_pop();
            val_pop();
            }
          }
        }
      else            //discard this token
        {
        if (yychar == 0)
          return 1; //yyabort
        if (yydebug)
          {
          yys = null;
          if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
          if (yys == null) yys = "illegal-symbol";
          debug("state "+yystate+", error recovery discards token "+yychar+" ("+yys+")");
          }
        yychar = -1;  //read another
        }
      }//end error recovery
    }//yyn=0 loop
    if (!doaction)   //any reason not to proceed?
      continue;      //skip action
    yym = yylen[yyn];          //get count of terminals on rhs
    if (yydebug)
      debug("state "+yystate+", reducing "+yym+" by rule "+yyn+" ("+yyrule[yyn]+")");
    if (yym>0)                 //if count of rhs not 'nil'
      yyval = val_peek(yym-1); //get current semantic value
    yyval = dup_yyval(yyval); //duplicate yyval if ParserVal is used as semantic value
    switch(yyn)
      {
//########## USER-SUPPLIED ACTIONS ##########
case 1:
//#line 19 "sintatico.y"
{new Analise((Decls)val_peek(0).obj);}
break;
case 2:
//#line 23 "sintatico.y"
{yyval.obj = new Decls(val_peek(4).ival, val_peek(3).sval, 1 ,val_peek(2).obj, val_peek(0).obj  ); System.out.println( lexer.getLineNum()+1);}
break;
case 3:
//#line 24 "sintatico.y"
{yyval.obj = new Decls(val_peek(3).ival, val_peek(2).sval, 2, val_peek(1).obj, val_peek(0).obj ); System.out.println( lexer.getLineNum()+1);}
break;
case 4:
//#line 25 "sintatico.y"
{yyval.obj = new Decls(val_peek(2).ival, val_peek(1).sval, 3, val_peek(0).obj); System.out.println( lexer.getLineNum()+1);}
break;
case 5:
//#line 30 "sintatico.y"
{yyval.obj = new VarDecl(1);  }
break;
case 6:
//#line 31 "sintatico.y"
{yyval.obj = new VarDecl(val_peek(1).sval, 2, val_peek(0).obj); }
break;
case 7:
//#line 32 "sintatico.y"
{yyval.obj = new VarDecl(val_peek(2).sval, 3, val_peek(0).obj);}
break;
case 8:
//#line 33 "sintatico.y"
{yyval.obj = new VarDecl(val_peek(2).sval, 4, val_peek(0).obj); }
break;
case 9:
//#line 36 "sintatico.y"
{yyval.obj = new FuncDecl(val_peek(2).obj, val_peek(0).obj) ;   }
break;
case 10:
//#line 40 "sintatico.y"
{yyval.obj = new ParamDeclList() ;}
break;
case 11:
//#line 41 "sintatico.y"
{yyval.obj  = new ParamDeclList(val_peek(0).obj);}
break;
case 12:
//#line 45 "sintatico.y"
{yyval.obj = new ParamDeclListTail(val_peek(0).obj);}
break;
case 13:
//#line 46 "sintatico.y"
{yyval.obj = new ParamDeclListTail(val_peek(2).obj , val_peek(0).obj) ;}
break;
case 14:
//#line 49 "sintatico.y"
{yyval.obj = new ParamDecl(val_peek(1).ival, val_peek(0).sval, 1);}
break;
case 15:
//#line 50 "sintatico.y"
{yyval.obj = new ParamDecl(val_peek(3).ival, val_peek(2).sval, 2);}
break;
case 16:
//#line 53 "sintatico.y"
{yyval.obj = new Block(val_peek(2).obj, val_peek(1).obj);}
break;
case 17:
//#line 54 "sintatico.y"
{yyval.obj = new Block(val_peek(1).obj);}
break;
case 18:
//#line 57 "sintatico.y"
{yyval.obj = new VarDeclList(1);}
break;
case 19:
//#line 58 "sintatico.y"
{yyval.obj = new VarDeclList(val_peek(4).ival, val_peek(3).sval, 2, val_peek(2).obj, val_peek(0).obj);}
break;
case 20:
//#line 61 "sintatico.y"
{yyval = new ParserVal(1);}
break;
case 21:
//#line 62 "sintatico.y"
{yyval = new ParserVal(2);}
break;
case 22:
//#line 65 "sintatico.y"
{yyval.obj = new StmtList(val_peek(0).obj);}
break;
case 23:
//#line 66 "sintatico.y"
{yyval.obj = new StmtList(val_peek(1).obj, val_peek(0).obj);}
break;
case 24:
//#line 70 "sintatico.y"
{yyval.obj = new Stmt(1);}
break;
case 25:
//#line 71 "sintatico.y"
{yyval.obj = new Stmt(2, val_peek(1).obj);}
break;
case 26:
//#line 72 "sintatico.y"
{yyval.obj = new Stmt(3, val_peek(1).obj);}
break;
case 27:
//#line 73 "sintatico.y"
{yyval.obj = new Stmt(16,val_peek(1).sval);}
break;
case 28:
//#line 74 "sintatico.y"
{yyval.obj = new Stmt(4);}
break;
case 29:
//#line 75 "sintatico.y"
{yyval.obj = new Stmt(val_peek(1).sval, 5);}
break;
case 30:
//#line 76 "sintatico.y"
{yyval.obj = new Stmt(14, val_peek(4).sval, val_peek(2).sval);}
break;
case 31:
//#line 77 "sintatico.y"
{yyval.obj = new Stmt(15, val_peek(4).sval, val_peek(2).sval);}
break;
case 32:
//#line 78 "sintatico.y"
{yyval.obj = new Stmt(6, val_peek(1).obj);}
break;
case 33:
//#line 79 "sintatico.y"
{yyval.obj = new Stmt(val_peek(0).sval ,7);}
break;
case 34:
//#line 80 "sintatico.y"
{yyval.obj = new Stmt(9);}
break;
case 35:
//#line 81 "sintatico.y"
{yyval.obj = new Stmt(8);}
break;
case 36:
//#line 82 "sintatico.y"
{yyval.obj = new Stmt(10, val_peek(2).obj, val_peek(0).obj);}
break;
case 37:
//#line 83 "sintatico.y"
{yyval.obj = new Stmt(11, val_peek(4).obj, val_peek(2).obj, val_peek(0).obj);}
break;
case 38:
//#line 84 "sintatico.y"
{yyval.obj = new Stmt(12, val_peek(2).obj, val_peek(0).obj);}
break;
case 39:
//#line 85 "sintatico.y"
{yyval.obj = new Stmt(13, val_peek(0).obj);}
break;
case 40:
//#line 89 "sintatico.y"
{yyval.obj = new Expr(val_peek(2).obj, val_peek(0).obj);}
break;
case 41:
//#line 90 "sintatico.y"
{yyval.obj = new Expr(val_peek(0).obj);}
break;
case 42:
//#line 93 "sintatico.y"
{yyval.obj = new BinaryExpr(val_peek(2).obj, val_peek(1).obj, val_peek(0).obj);}
break;
case 43:
//#line 94 "sintatico.y"
{yyval.obj = new BinaryExpr(val_peek(0).obj);}
break;
case 44:
//#line 97 "sintatico.y"
{yyval.obj = new UnaryExpr(val_peek(1).obj, val_peek(0).obj );}
break;
case 45:
//#line 98 "sintatico.y"
{yyval.obj = new UnaryExpr(val_peek(0).obj);}
break;
case 46:
//#line 102 "sintatico.y"
{yyval.obj  =  new PostFixExpr(val_peek(3).sval, 2, val_peek(1).obj);}
break;
case 47:
//#line 103 "sintatico.y"
{yyval.obj  =  new PostFixExpr(val_peek(2).sval, 3);}
break;
case 48:
//#line 104 "sintatico.y"
{yyval.obj  =  new PostFixExpr(val_peek(0).sval, 6);}
break;
case 49:
//#line 105 "sintatico.y"
{yyval.obj  =  new PostFixExpr(val_peek(0).obj, 7);}
break;
case 50:
//#line 106 "sintatico.y"
{yyval.obj  =  new PostFixExpr(val_peek(1).obj, 1);}
break;
case 51:
//#line 109 "sintatico.y"
{yyval.obj  =  new PostFixExpr(val_peek(3).sval, 10, val_peek(1).obj);}
break;
case 52:
//#line 113 "sintatico.y"
{yyval.obj = new Constant(val_peek(0).sval, 1);}
break;
case 53:
//#line 114 "sintatico.y"
{yyval.obj = new Constant(val_peek(0).sval, 2);}
break;
case 54:
//#line 115 "sintatico.y"
{}
break;
case 55:
//#line 118 "sintatico.y"
{yyval.obj = new ArgumentList(val_peek(0).obj);}
break;
case 56:
//#line 119 "sintatico.y"
{yyval.obj = new ArgumentList(val_peek(2).obj, val_peek(0).obj);}
break;
case 57:
//#line 123 "sintatico.y"
{yyval.obj  =  new UnaryOp(1);}
break;
case 58:
//#line 124 "sintatico.y"
{yyval.obj  =  new UnaryOp(2);}
break;
case 59:
//#line 127 "sintatico.y"
{yyval.obj = new Binop(val_peek(0).obj);}
break;
case 60:
//#line 128 "sintatico.y"
{yyval.obj = new Binop(val_peek(0).obj);}
break;
case 61:
//#line 129 "sintatico.y"
{yyval.obj = new Binop(val_peek(0).obj);}
break;
case 62:
//#line 133 "sintatico.y"
{yyval.obj  =  new AritmOp(1);}
break;
case 63:
//#line 134 "sintatico.y"
{yyval.obj  =  new AritmOp(2);}
break;
case 64:
//#line 135 "sintatico.y"
{yyval.obj  =  new AritmOp(3);}
break;
case 65:
//#line 136 "sintatico.y"
{yyval.obj  =  new AritmOp(4);}
break;
case 66:
//#line 138 "sintatico.y"
{yyval.obj  =  new RelOp(5);}
break;
case 67:
//#line 139 "sintatico.y"
{yyval.obj  =  new RelOp(6);}
break;
case 68:
//#line 140 "sintatico.y"
{yyval.obj  =  new RelOp(7);}
break;
case 69:
//#line 141 "sintatico.y"
{yyval.obj  =  new RelOp(8);}
break;
case 70:
//#line 142 "sintatico.y"
{yyval.obj  =  new RelOp(9);}
break;
case 71:
//#line 143 "sintatico.y"
{yyval.obj  =  new RelOp(10);}
break;
case 72:
//#line 147 "sintatico.y"
{yyval.obj  =  new BooleanOp(11);}
break;
case 73:
//#line 148 "sintatico.y"
{yyval.obj  =  new BooleanOp(12);}
break;
//#line 878 "Parser.java"
//########## END OF USER-SUPPLIED ACTIONS ##########
    }//switch
    //#### Now let's reduce... ####
    if (yydebug) debug("reduce");
    state_drop(yym);             //we just reduced yylen states
    yystate = state_peek(0);     //get new state
    val_drop(yym);               //corresponding value drop
    yym = yylhs[yyn];            //select next TERMINAL(on lhs)
    if (yystate == 0 && yym == 0)//done? 'rest' state and at first TERMINAL
      {
      if (yydebug) debug("After reduction, shifting from state 0 to state "+YYFINAL+"");
      yystate = YYFINAL;         //explicitly say we're done
      state_push(YYFINAL);       //and save it
      val_push(yyval);           //also save the semantic value of parsing
      if (yychar < 0)            //we want another character?
        {
        yychar = yylex();        //get next character
        if (yychar<0) yychar=0;  //clean, if necessary
        if (yydebug)
          yylexdebug(yystate,yychar);
        }
      if (yychar == 0)          //Good exit (if lex returns 0 ;-)
         break;                 //quit the loop--all DONE
      }//if yystate
    else                        //else not done yet
      {                         //get next state and push, for next yydefred[]
      yyn = yygindex[yym];      //find out where to go
      if ((yyn != 0) && (yyn += yystate) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
        yystate = yytable[yyn]; //get new state
      else
        yystate = yydgoto[yym]; //else go to new defred
      if (yydebug) debug("after reduction, shifting from state "+state_peek(0)+" to state "+yystate+"");
      state_push(yystate);     //going again, so push state & val...
      val_push(yyval);         //for next action
      }
    }//main loop
  return 0;//yyaccept!!
}
//## end of method parse() ######################################



//## run() --- for Thread #######################################
/**
 * A default run method, used for operating this parser
 * object in the background.  It is intended for extending Thread
 * or implementing Runnable.  Turn off with -Jnorun .
 */
public void run()
{
  yyparse();
}
//## end of method run() ########################################



//## Constructors ###############################################
/**
 * Default constructor.  Turn off with -Jnoconstruct .

 */
public Parser()
{
  //nothing to do
}


/**
 * Create a parser, setting the debug to true or false.
 * @param debugMe true for debugging, false for no debug.
 */
public Parser(boolean debugMe)
{
  yydebug=debugMe;
}
//###############################################################



}
//################### END OF CLASS ##############################
